package cn.ht.jywrwater.module.ht.dal.mysql.waterdevices;

import java.util.*;

import cn.ht.jywrwater.framework.common.pojo.PageResult;
import cn.ht.jywrwater.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ht.jywrwater.framework.mybatis.core.mapper.BaseMapperX;
import cn.ht.jywrwater.module.ht.dal.dataobject.waterdevices.WaterDevicesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.ht.jywrwater.module.ht.controller.admin.waterdevices.vo.*;

/**
 * 设备 Mapper
 *
 * @author hzx
 */
@Mapper
public interface WaterDevicesMapper extends BaseMapperX<WaterDevicesDO> {

    default PageResult<WaterDevicesDO> selectPage(WaterDevicesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WaterDevicesDO>()
                .eqIfPresent(WaterDevicesDO::getDeviceCode, reqVO.getDeviceCode())
                .eqIfPresent(WaterDevicesDO::getVillage, reqVO.getVillage())
                .eqIfPresent(WaterDevicesDO::getContractor, reqVO.getContractor())
                .betweenIfPresent(WaterDevicesDO::getInstallationTime, reqVO.getInstallationTime())
                .eqIfPresent(WaterDevicesDO::getDeviceType, reqVO.getDeviceType())
                .orderByDesc(WaterDevicesDO::getId));
    }

    default List<WaterDevicesDO> selectList(WaterDevicesExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WaterDevicesDO>()
                .eqIfPresent(WaterDevicesDO::getDeviceCode, reqVO.getDeviceCode())
                .eqIfPresent(WaterDevicesDO::getVillage, reqVO.getVillage())
                .eqIfPresent(WaterDevicesDO::getContractor, reqVO.getContractor())
                .betweenIfPresent(WaterDevicesDO::getInstallationTime, reqVO.getInstallationTime())
                .eqIfPresent(WaterDevicesDO::getDeviceType, reqVO.getDeviceType())
                .orderByDesc(WaterDevicesDO::getId));
    }

}
